﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Telerik.Web.UI;

namespace ProjectSem40701.Admin
{
    public partial class Question : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
           
        }

        protected void lblCreatedDate_DataBinding(object sender, EventArgs e)
        {
            Label lblCreatedDate = (Label)sender;
            lblCreatedDate.Text = Convert.ToDateTime(lblCreatedDate.Text).ToString("dd/MM/yyyy");
        }

        protected void cbbStatus_SelectedIndexChanged(object sender, EventArgs e)
        {
            try
            {
                DropDownList cbbStatus = sender as DropDownList;
                if (cbbStatus.SelectedValue.ToString() != "-1")
                {
                    this.rgrQuestion.MasterTableView.GetColumn("QuestionStatus").CurrentFilterValue
                        = cbbStatus.SelectedValue;
                    GridFilteringItem filterItem
                        = this.rgrQuestion.MasterTableView.GetItems(GridItemType.FilteringItem)[0] as GridFilteringItem;
                    filterItem.FireCommandEvent("Filter", new Pair("EqualTo", "QuestionStatus"));

                }
                else
                {
                    GridFilteringItem filterItem = this.rgrQuestion.MasterTableView.GetItems(GridItemType.FilteringItem)[0] as GridFilteringItem;
                    filterItem.FireCommandEvent("Filter", new Pair("NoFilter", "QuestionStatus"));
                }
                this.lblSelectedIndex.Text = cbbStatus.SelectedValue.ToString();
            }
            catch (Exception exc)
            {
                exc.ToString();
            }
        }
        protected void cbbStatus_PreRender(object sender, EventArgs e)
        {
            DropDownList cbbStatus = (DropDownList)sender;
            foreach (ListItem item in cbbStatus.Items)
            {
                if (item.Value.ToString() == this.lblSelectedIndex.Text.ToString())
                {
                    item.Selected = true;
                }
            }
        }

        protected void QuestionStatusLabel_DataBinding1(object sender, EventArgs e)
        {
            try
            {
                Label QuestionStatusLabel = sender as Label;
                QuestionStatusLabel.Text = QuestionStatusLabel.Text == "1" ? "Kích hoạt" : "Khóa";
            }
            catch
            {
                //bao that bai
            }

        }
    }
}
